import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JOptionPane;



public class MultiplyCheckerEngine implements ActionListener {
	MultiplyChecker parent;
	int x,y;
	
	MultiplyCheckerEngine(MultiplyChecker parent){
		this.parent = parent;
		
		generateNewPair();
		this.parent.label.setText(x + " x " + y + " = ");
		
	}
	
	public void generateNewPair(){
		Random rand = new Random();
		
		x = rand.nextInt(9) + 1;
		y = rand.nextInt(9) + 1;
		
	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {

		if (x * y == Integer.parseInt(parent.tf.getText())){
			parent.answerLabel.setText("Correct!");
			generateNewPair();
			parent.label.setText(x + " x " + y + " = ");
			parent.tf.setText("");
		} else {
			parent.answerLabel.setText("Incorrect!2");
		}

	}

}
